//
//  ComplainController.m
//  jang
//
//  Created by lee han on 11/06/2017.
//  Copyright © 2017 lee han. All rights reserved.
//

#import "ComplainController.h"
#import "CommonView.h"

@interface ComplainController ()

@end

@implementation ComplainController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.navigationItem.backBarButtonItem setTitle:@""];
    
    _mInputTitle.delegate = self;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)onClickSubmit:(id)sender {
    [_mInputTitle resignFirstResponder];
    [_mInputContext resignFirstResponder];
    
    if ([_mInputTitle.text length] == 0 || [_mInputContext.text length] == 0) {
        [CommonView addAlertView:self Text:@"请输入有效信息"];
        return;
    }
    
    NSMutableDictionary* data = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                 _mInputTitle.text,  @"title",
                                 _mInputContext.text, @"context",
                                 nil];
    
    [[network sharedInstance] startHttpRequest:self Data:data functionType:NetworkFunctionType_Complain];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark networkDelegate

- (void)parserResult:(NSDictionary *)response functionType:(NSInteger)type {
    if([[response objectForKey:@"status"] integerValue] == 1){
        _mInputTitle.text = @"";
        _mInputContext.text = @"140字以内";
        [CommonView addAlertView:self Text:@"投诉成功"];
    }
    else{
        [CommonView addAlertView:self Text:@"投诉错误"];
    }
}
//end networkDelegate

#pragma mark UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [_mInputContext becomeFirstResponder];
    return YES;
}
//end UITextFieldDelegate

@end
